class Timer{
    countdown(end, update, handle){ //截止时间、
        const now = new Date().getTime()
        const _this = this
        if(now-end>0){
            handle.call(_this) //call?
        }else{
            let last_time = end -now 
            const px_d = 1000 * 60 * 60 * 24
            const px_h = 1000*60*60
            const px_m = 1000*60
            const px_s = 1000
            let d = Math.floor(last_time/px_d)
            let h = Math.floor((last_time-d*px_d)/px_h)
            let m = Math.floor((last_time-d*px_d-h*px_h)/px_m)
            let s = Math.floor((last_time - d * px_d - h * px_h-m*px_m)/px_s)
            let r = []
            d > 0 ? r.push(` < em > ${ d }</em > 天`):r
            h > 0 || r.length ? r.push(`<em> ${ h }</em> 时`):r
            m > 0 || r.length ? r.push(` <em> ${ m }</em> 分`):r
            s > 0 || r.length ? r.push(` <em> ${ s }</em> 秒`):r
            _this.last_time = r.join('')
            update.call(_this,_this.last_time) //update??
            setTimeout(() => {
                _this.countdown(end,update,handle)
            }, 1000);
        }
    }
}
export default Timer